<template>
  <div class="attest-wrap">
    <van-nav-bar
      title="绑定账号"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <div v-if="type == 0" class="fixed" style="top:50px;left:0;right: 0;bottom: 0">
      <!-- <div @click="original" class="card">
        <h2>绑定原用户</h2>
      </div> -->
      <div @click="create" class="card">
        <h2 v-text="createText"></h2>
      </div>
    </div>
    <div class="main">
      <div v-if="type == 1">
        <van-cell-group>
        <van-field
          v-model="pamars.mobile"
          required
          clearable
          label="手机号"
          placeholder="请输入手机号"
        />
      </van-cell-group>
      <van-button @click="bind" type="primary">确定绑定</van-button>
      </div>
    </div>
  </div>
</template>

<script>
import { Notify } from 'vant';
export default {
  name: 'Attest',
  data(){
    return {
      type: 0,
      createText:null
    }
  },
  created(){
    console.log(this.$route)
  },
  mounted(){
    this.pamars.open_id= this.$route.query.openid;
    this.pamars.parent_id = this.$route.query.parent_id;
    this.pamars.token = this.$route.query.token;
    this.createText = '自动注册中 · · ·'
    this.create();
  },
  methods:{
    onClickLeft(){
      this.$router.go(-1)
    },
    original(){
      this.type = 1;
    },
    bind(){
      const sub =  this.axios.post('/api/wechatofficial/1/bind',this.pamars);
      sub.then(result=>{
        Notify({ type: 'success', message: result.data.message,'onClose':() =>{
          this.$router.push({ path:'/'});
        }});
      })
      .catch(error=>{
        Notify({ type: 'success', message: error.data.message});
      })
    },
    
  }
}
</script>
<style scoped>
.card {
  background-color: white;
  height: 40vh;
  width: 100%;
  text-align: center;
  padding: 10px 10px;
  margin-top: 10px;
}
.card h2 {
  line-height: 40vh;
  margin: 0;
}
</style>